package addon.w3.mdx.com;

import java.io.IOException;

import addon.w3.mdx.LEDataInputStream;
import addon.w3.mdx.MDXException;
import addon.w3.mdx.MDXParentCOM;

/**
 * --VRTX						// [Vertices]
	long	nvrts;
	struct {
		float	x,y,z;
	} vertices[nvrts];
 * @author madjk
 *
 */
public class MDXVertexes extends MDXParentCOM {
	int length = -1;
	public MDXVertexCOM vrtxs[];
	
	public String getTag() {
		return "VRTX";
	}
	
	public int getVertexSize() {
		return vrtxs.length;
	}
	
	public float[] getVertex(int index) {
		return vrtxs[index].vertex;
	}
	
	public void _decode(LEDataInputStream ins) throws IOException, MDXException {
		length = ins.readInt();
		vrtxs = new MDXVertexCOM[length];
		for(int i=0;i<vrtxs.length;i++) {
			vrtxs[i] = new MDXVertexCOM();
			vrtxs[i].decode(ins);
		}
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("TAG : "+getTag());
		sb.append("\n\tELEN : "+length);
		if(vrtxs != null && vrtxs.length > 0) sb.append("\n\tVRTXS[] : "+vrtxs.length);
		return sb.toString();
	}

	@Override
	public boolean isImplicitTag() {
		// TODO Auto-generated method stub
		return true;
	}
}